<template>
  <div class="mod-menu">
    <div>
      <el-form :inline="true" :model="dataForm">
        <el-form-item label="商品名称">
          <el-input v-model="dataForm.userName" placeholder="商品名称" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
           <el-button @click="addOrUpdateHandle()">添加</el-button>
        </el-form-item>
      </el-form>
    </div>


    <el-table :data="dataList" row-key="Id" border style="width: 100%; ">
      <el-table-column prop="name" header-align="center" label="商品名称">
      </el-table-column>
      <el-table-column prop="name" header-align="center" label="积分数量">
      </el-table-column>
      <el-table-column prop="name" header-align="center" label="可兑数量">
      </el-table-column>
      <el-table-column prop="name" header-align="center" label="已兑换数量">
      </el-table-column>
      <el-table-column prop="name" header-align="center" label="每人限兑">
      </el-table-column>
      <el-table-column prop="name" header-align="center" label="商品排序">
      </el-table-column>
      <el-table-column fixed="right" header-align="center" align="center"  label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">编辑</el-button>
          <el-button  type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 弹窗, 新增 / 修改 -->
    <is-add-update v-if="addOrUpdateVisible" ref="isAddUpdate"></is-add-update>
  </div>
</template>

<script>
  import IsAddUpdate from './is-add-update'
  export default {
    data () {
      return {
        dataForm: {},
        dataList: [],
        dataListLoading: false,
        addOrUpdateVisible: false
      }
    },
    components: {
      IsAddUpdate
    },
    methods: {
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.isAddUpdate.init(id)
        })
      }
    }
  }
</script>

<style lang="scss">
  .mt30{
    margin-top: 30px;
  }
</style>
